﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _01Test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("使用while循环实现计算1+1/2+2/3+...+99/100：");
        float i = 1F;
        float s = 1F;
        while (i<100) {
            s = s + (i/ (i + 1));
            i++;
        }
        Response.Write("结果是："+s+"<br>");
        Response.Write("使用do-while循环实现计算1+1/2+2/3+...+99/100：");
        float i2 = 1F;
        float s2 = 1F;
        do{
            s2 = s2 + (i2 / (i2 + 1));
            i2++;
        } while (i2 < 100);
        Response.Write("结果是：" + s2 + "<br>");
        Response.Write("使用for循环实现计算1+1/2+2/3+...+99/100：");
        float s3 = 1F;
        for (float i3=1F;i3<100;i3++) {
            s3 = s3 + (i3/ (i3 + 1));
        }
        Response.Write("结果是：" + s3);
    }
}